package updater;

import java.awt.EventQueue;
import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.JFrame;

public class Filechooser extends JFileChooser {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JFrame root;
	private JFileChooser fc;
	public Boolean isSet = false; 

	/**
	 * Launch the application.
	 */
	public static void start() {
		EventQueue.invokeLater(() -> {
                    try {
                        Filechooser fc1 = new Filechooser();
                        fc1.root.setVisible(true);
                    }catch (Exception e) {
                    }
                });
	}

	/**
	 * Create the application.
	 */
	public Filechooser() {
		initialize();
	}
	
	/**
	 * Create the frame.
	 * @return 
	 */
	private void initialize() {
		root = new JFrame();
		root.setTitle("Wot Mods Updater");
		root.setBounds(100, 100, 640, 480);
		
		fc = new JFileChooser();
		fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
		fc.setBounds(0, 0, 640, 480);
		root.getContentPane().add(fc);
		
	}

	
	
	public File getDirectory(){
		int rueckgabeWert = fc.showOpenDialog(null);
        
        /* Abfrage, ob auf "Oeffnen" geklickt wurde */
        if(rueckgabeWert == JFileChooser.APPROVE_OPTION)
        {
        	return fc.getSelectedFile();
        }
        else{
        	
        	return null;
        }
	}

	
}
